package com.hzhr.iot.cqgas.ds.controller;

import com.hzhr.iot.cqgas.ds.dao.device.example.DevIotDeviceTypeDao;
import com.hzhr.iot.cqgas.ds.entity.device.DevIotDeviceTypeEntity;
import com.hzhr.iot.cqgas.ds.entity.device.DevIotDeviceTypeExample;
import com.hzhr.iot.cqgas.ds.service.IotDeviceTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class IotDeviceTypeController {
    @Autowired
    IotDeviceTypeService iotDeviceTypeService;
    @Autowired
    DevIotDeviceTypeDao devIotDeviceTypeDao;

    @RequestMapping(value = "/syncIotDeviceType")
    public void syncIotDeviceType() {
        DevIotDeviceTypeEntity devIotDeviceTypeEntity = new DevIotDeviceTypeEntity();
        devIotDeviceTypeEntity.setState("3");
        DevIotDeviceTypeExample devIotDeviceTypeExample = new DevIotDeviceTypeExample();
        devIotDeviceTypeExample.createCriteria().andOutIdIsNotNull();
        devIotDeviceTypeDao.updateByExampleSelective(devIotDeviceTypeEntity, devIotDeviceTypeExample);

        iotDeviceTypeService.syncIotDeviceType();

        devIotDeviceTypeExample = new DevIotDeviceTypeExample();
        devIotDeviceTypeExample.createCriteria().andStateEqualTo("3");
        devIotDeviceTypeDao.deleteByExample(devIotDeviceTypeExample);
    }
}
